//
//  BankCardPopCell.m
//  PPDL
//
//  Created by 王洋 on 2019/7/29.
//  Copyright © 2019 王洋. All rights reserved.
//

#import "BankCardPopCell.h"

@interface BankCardPopCell ()


@property (weak, nonatomic) IBOutlet UILabel *bankName;
@property (weak, nonatomic) IBOutlet UIButton *bankCardSelectBtn;


@end

@implementation BankCardPopCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)fillCellWithModel:(BankCardModel *)model {
    
    
    self.model = model;
    self.bankName.text =[NSString stringWithFormat:@"%@ %@",model.bankName,model.bankCardID] ;

    [self.bankCardSelectBtn setImage:model.isDefault?[UIImage imageNamed:@"admire_bg"]:[UIImage imageNamed:@"empty_bg"] forState:UIControlStateNormal];

//    if (model.isDefault) {
//        [self.bankCardSelectBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
//    } else {
//        [self.bankCardSelectBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
//    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (IBAction)selectBankCardClicked:(id)sender {
    
    //1、改变按钮状态    2、刷新数据源
    self.model.isDefault = !self.model.isDefault;
    
    [self.bankCardSelectBtn setImage:self.model.isDefault?[UIImage imageNamed:@"admire_bg"]:[UIImage imageNamed:@"empty_bg"]
                           forState:UIControlStateNormal];
    
    if (self.refreshItemModel) {
        self.refreshItemModel(self.model);
    }
    
    
}


@end
